<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    // function sum(a, b) {
    //   var b = b || 100;  // ||运算符 赋值 前面的表达式为假 赋值后面的值
    //   return a + b
    // }
    // console.log(sum(8))

    // es6 函数的形参的默认值
    function sum(a, b = 100, c = "50", arr = [1, 2, 3]) {
      console.log(a + b)
      console.log(arr)
    }
    sum(80, 50, 99, [7, 8, 9])
    //剩余参数...rest  整理参数为数组
    function run(a = 8, ...rest) {
      console.log(rest)
    }
    run(1, 2, 3, 4, 5, 6)

  </script>
</body>

</html>